package com.wwj.web.controller.project;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
import com.wwj.system.project.service.ITestUserService;
import com.wwj.system.project.entity.TestUser;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wwj
 * @since 2024-07-07
 */
@RestController
@RequestMapping("/test")
	public class TestUserController {

    @Resource
    private ITestUserService testUserService;

    // 新增或者更新
    @PostMapping
    public boolean save(@RequestBody TestUser testUser) {
		return testUserService.saveOrUpdate(testUser);
    }

    // 删除
    @DeleteMapping("/{id}")
    public boolean delete(@PathVariable Integer id) {
		return testUserService.removeById(id);
    }

    // 查询所有数据
    @GetMapping
    public List<TestUser> findAll() {
        return testUserService.list();
    }

    // 根据id查询
    @GetMapping("/{id}")
    public TestUser findOne(@PathVariable Integer id) {
		return testUserService.getById(id);
    }

    // 分页查询
    @GetMapping("/page")
    public Page<TestUser> findPage(@RequestParam Integer pageNum,@RequestParam Integer pageSize) {
       return testUserService.page(new Page<>(pageNum, pageSize));
    }
}

